package View;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import javax.swing.*;

import mvc.Model.Department;
import mvc.Model.Employee;
import mvc.Model.Model;
/**
 * Created with IntelliJ IDEA.
 * User: Anastasia
 * Date: 27.11.14
 * Time: 23:49
 * To change this template use File | Settings | File Templates.
 */
public class ViewFrame extends JFrame {
    /*
    private int select;
    private Model model;
    private Employee employee;


    private JLabel Label;
    private JLabel namelabel= new JLabel("Имя");;
    private JLabel surnamelabel= new JLabel("Отчество");;
    private JLabel lastnamelabel = new JLabel("Фамилия");;
    private JLabel departmentlabel = new JLabel("Департамент");
    private JLabel paylabel = new JLabel("Зарплата");
    private JLabel  phonelabel = new JLabel("Телефон");

    private JButton addEmployee  ;
    private JButton removeEmployee;
    private JButton getEmployee;

    private JButton saveList;
    private JButton loadlist;
    private  JPanel panel;



    private JTextField name = new JTextField(10);
    private JTextField surname;
    private JTextField lastname;
    private JTextField department;
    private JTextField pay;
    private JTextField phone;


    private JTextArea list;
    private JButton addEmployeeTwo;

    public ViewFrame()
    {
         int select=-1;
         Model model=null;

          list = new JTextArea();
          Label = new JLabel();
          namelabel=new JLabel();
          surnamelabel=new JLabel();
          lastnamelabel=new JLabel();
          departmentlabel =new JLabel();
          paylabel=new JLabel();
          phonelabel=new JLabel();

          addEmployee = new JButton() ;
          removeEmployee = new JButton();
          getEmployee = new JButton();
           panel = new JPanel();



          name = new JTextField();
          surname = new JTextField();
          lastname= new JTextField();
          department= new JTextField();
          pay= new JTextField();
          phone= new JTextField();

    }

    public ViewFrame(Model model)
    {

        super("MVC");//Заголовок окна
        this.model = model;
        setBounds(800,800,900,900);
         panel = new JPanel();
        list = new JTextArea();
        panel.setLayout(null);
        addEmployee = new JButton("Добавить сотрудника");
        addEmployee.setBounds(5, 5, 200, 30);
        panel.add(addEmployee);
        removeEmployee = new JButton("Удалить сотрудника");
        removeEmployee.setBounds(220, 5, 200, 30);
        panel.add(removeEmployee);
        getEmployee = new JButton("Получить сотрудника по id");
        getEmployee.setBounds(440, 5, 200, 30);
        panel.add(getEmployee);

        saveList = new JButton("Сохранить список");
        saveList.setBounds(440, 40, 200, 30);
        panel.add(saveList);

        loadlist = new JButton("Загрузить список");
        loadlist.setBounds(440, 80, 200, 30);
        panel.add(loadlist);

        Label = new JLabel("Текущее количество сотрудников:" + model.getCount());
        Label.setBounds(100,40,300,30);
        panel.add(Label);
        namelabel = new JLabel("Имя");
        namelabel.setBounds(100,100,80,30);
        panel.add(namelabel) ;

        name = new JTextField();
        name.setBounds(200, 100, 200, 30);

        panel.add(name);


        surnamelabel = new JLabel("Отчество");
        surnamelabel.setBounds(100,150,80,30);
        panel.add(surnamelabel) ;

        surname = new JTextField();
        surname.setBounds(200, 150, 200, 30);

        panel.add(surname);


        lastnamelabel = new JLabel("Фамилия");
        lastnamelabel.setBounds(100,200,80,30);
        panel.add(lastnamelabel) ;

        lastname = new JTextField();
        lastname.setBounds(200, 200, 200, 30);

        panel.add(lastname);

        departmentlabel = new JLabel("Департамент");
        departmentlabel.setBounds(100,250,80,30);
        panel.add(departmentlabel) ;

        department = new JTextField();
        department.setBounds(200, 250, 200, 30);


        panel.add(department);


        paylabel = new JLabel("Зарплата");
        paylabel.setBounds(100,300,80,30);
        panel.add(paylabel) ;

        pay = new JTextField();
        pay.setBounds(200, 300, 200, 30);

        panel.add(pay);



        phonelabel = new JLabel("Телефон");
        phonelabel.setBounds(100,350,80,30);
        panel.add(phonelabel) ;

        panel.validate();


        phone = new JTextField();
        phone.setBounds(200, 350, 200, 30);

        panel.add(phone);

        list = new JTextArea("Модель");
        //new JList<>()
        list.setBounds(100,400,300,300);
        panel.add(list);


        panel.validate();



       this.add(panel);
        setPreferredSize(new Dimension(500, 800));

  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }


    public void addActionListnerForAdd(ActionListener addlistner)
    {
        addEmployee.addActionListener(addlistner);
    }


    public void addListnerForAddTwo(ActionListener addlist)
    {
        addEmployeeTwo.addActionListener(addlist);
    }

    public void addActionForSave(ActionListener saver)
    {
        saveList.addActionListener(saver);
    }


    public void addActionForLoad(ActionListener loader)
    {
        loadlist.addActionListener(loader);
    }


 /* public void initListeners() {

        addEmployee.addActionListener(new ActionListener() {
           @Override  public void actionPerformed(ActionEvent e) {






           }
        });


        removeEmployee.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              //  select=2;

            }

        });

       addEmployeeTwo.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {
              // select = 1;


              ;
           }

       });


    } */
        /*
    public int getSelect()
    {
        return select;
    }


    public void addFormsForNewEmployee ()
    {

       JButton addEmployeeTwo = new JButton("Добавить");
        addEmployeeTwo.setBounds(500, 100, 100,30);
        panel.add(addEmployeeTwo);
       panel.validate();
        namelabel = new JLabel("Имя");
        namelabel.setBounds(100,100,80,30);
        panel.add(namelabel) ;

        name = new JTextField();
        name.setBounds(200, 100, 200, 30);

        panel.add(name);


        surnamelabel = new JLabel("Отчество");
        surnamelabel.setBounds(100,150,80,30);
        panel.add(surnamelabel) ;

        surname = new JTextField();
        surname.setBounds(200, 150, 200, 30);

        panel.add(surname);


        lastnamelabel = new JLabel("Фамилия");
        lastnamelabel.setBounds(100,200,80,30);
        panel.add(lastnamelabel) ;

        lastname = new JTextField();
        lastname.setBounds(200, 200, 200, 30);

        panel.add(lastname);

        departmentlabel = new JLabel("Департамент");
        departmentlabel.setBounds(100,250,80,30);
        panel.add(departmentlabel) ;

        department = new JTextField();
        department.setBounds(200, 250, 200, 30);


        panel.add(department);


        paylabel = new JLabel("Зарплата");
        paylabel.setBounds(100,300,80,30);
        panel.add(paylabel) ;

        pay = new JTextField();
        pay.setBounds(200, 300, 200, 30);

        panel.add(pay);



        phonelabel = new JLabel("Телефон");
        phonelabel.setBounds(100,350,80,30);
        panel.add(phonelabel) ;

        panel.validate();


        phone = new JTextField();
        phone.setBounds(200, 350, 200, 30);

        panel.add(phone);
        panel.validate();

    }


    public Employee readnewEmployee()
    {
        Employee emp = new Employee();
        String name1 = name.getText();
        String namesur =surname.getText();
        String namelast = lastname.getText();
        String depart = department.getText();
        int pay1 = new Integer(pay.getText());
        int phone1 = new Integer(phone.getText());
        if(name1!=null&& namesur!=null&& namelast!=null && depart!=null&&pay.getText()!=null&& phone.getText()!=null)
        {
            emp.setName(name1);
            emp.setSurname(namesur);
            emp.setLastName(namelast);
            emp.setDepartment(new Department(depart));
            emp.setPay(pay1);
            emp.setPhoneNumber(phone1);
        }
        return emp;

    }

    public void printlist()
    {
        ArrayList<Employee> mod = model.getList();

        list.setText("");
        for(int i =0;i< mod.size();i++)
        {
            Employee emp = mod.get(i);
            list.append(emp.getName()+ " ");
            list.append(emp.getSurname()+" ");
            list.append(emp.getLastName()+" ");
            list.append(emp.getDepartment().getName()+" ");
            list.append(new Integer(emp.getPay()).toString()+" ");
            list.append(new Integer(emp.getPhoneNumber()).toString()+" \n");
        }
        panel.validate();

    }

    public void changeCount()
    {

        Label.setText("Текущее количество сотрудников:" + model.getCount());
        panel.validate();
    }

          */

}
